package com.dragon.blelibrary.bleutils;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

public class BleHelper {
	
    protected BluetoothAdapter mAdapter;
    protected Context mContext;
	
	public BleHelper(Context context) {
        this.mContext = context;
        BluetoothManager bManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
        this.mAdapter = bManager.getAdapter();
	}

    public boolean isBleValid() {
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1
                || !mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
            return false;
        }
        if (mAdapter == null) {
            return false;
        }

        return true;
    }

    public boolean isBluetoothEnable() {
        return mAdapter.isEnabled();
    }

    public boolean enable() {
        return mAdapter.enable();
    }
}
